#!/usr/bin/make -f

PACKAGE = lilypond-kde4
docdir = debian/tmp/usr/share/doc/$(PACKAGE)

build:
	$(checkdir)
	cmake . -DCMAKE_INSTALL_PREFIX=/usr
	make
	touch build
	
clean:
	$(checkdir)
	rm -rf debian/tmp
	rm -f build

binary-indep: checkroot build
	$(checkdir)

binary-arch: checkroot build
	$(checkdir)
	rm -rf debian/tmp
	install -d debian/tmp/DEBIAN $(docdir)
	$(MAKE) install DESTDIR=$$(pwd)/debian/tmp
	install -m 644 README $(docdir)
	cd $(docdir) && gzip -9 README
	dpkg-shlibdeps debian/tmp/usr/bin/ktexteditservice
	dpkg-gencontrol -isp
	chown -R root:root debian/tmp
	chmod -R u+w,go=rX debian/tmp
	dpkg --build debian/tmp ..

define checkdir
	test -f debian/rules
endef

binary: binary-indep binary-arch

checkroot:
	$(checkdir)
	test $$(id -u) = 0

.PHONY: binary binary-arch binary-indep clean checkroot
